package com.changgou.common.entity;

import com.changgou.common.enums.HttpStateEnum;

import java.io.Serializable;

public class HttpRespond<T> implements Serializable {

    private Integer status;
    private String message;
    private T data;

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public HttpRespond() {
    }

    public HttpRespond(Integer status) {
        this.status = status;
    }

    public HttpRespond(Integer status, String message) {
        this.status = status;
        this.message = message;
    }

    public HttpRespond(Integer status, String message, T data) {
        this.status = status;
        this.message = message;
        this.data = data;
    }

    public HttpRespond(HttpStateEnum httpStateEnum) {
        this.status = httpStateEnum.getStatus();
        this.message = httpStateEnum.getMessage();
    }

    public HttpRespond(HttpStateEnum httpStateEnum, T data) {
        this(httpStateEnum);
        this.data = data;
    }

    public static HttpRespond<Void> error() {
         return new HttpRespond<>(HttpStateEnum.UNKNOWN_EXCEPTION);
    }
}
